﻿@model Models.DataModel.ContributionRate

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
    String portid1 = string.Empty;
}

<h2 style="color: #e67e22">Create ContributionRate</h2>

@using (Html.BeginForm())
{
  
    @Html.AntiForgeryToken()

    <div class="form-horizontal">

        <hr />
        @Html.ValidationSummary(true)

        <div class="form-group">
            <div class="form-group">
                @Html.LabelFor(model => model.Year, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    <input type="number" name="Year" id="Year" value="@DateTime.Today.Year" min="1800" max="@DateTime.Today.Year">
                    @Html.ValidationMessageFor(model => model.Year)
                </div>
            </div>

            <div class="form-group">
                @Html.Label("Fund", new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.DropDownListFor(model => model.FundId, ViewBag.ListFund as SelectList, new { @style = "width: 150px; height:23px;" })
                    @Html.ValidationMessageFor(model => model.FundId)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.LaborType, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.LaborType)
                    @Html.ValidationMessageFor(model => model.LaborType)
                </div>
            </div>
            <div class="form-group">
                @Html.Label("Port", new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.DropDownListFor(model => model.PortId, ViewBag.ListPort as SelectList, new { @style = "width: 150px; height:23px;", @onchange = "LoadPortNumber()" })
                    @Html.ValidationMessageFor(model => model.PortId)
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(model => model.PortNumber, new { @class = "control-label col-md-2 " })
                <div class="col-md-10">
                    @Html.TextBoxFor(model => model.PortNumber, new {  @readonly = true })
                    @Html.ValidationMessageFor(model => model.PortNumber)
                </div>
            </div>
            <div class="form-group">
                @Html.LabelFor(model => model.Rate, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Rate)
                    @Html.ValidationMessageFor(model => model.Rate)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Percentage, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Percentage)
                    @Html.ValidationMessageFor(model => model.Percentage)
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="Create" class="btn btn-primary" />
                </div>
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
<script>
    function LoadPortNumber() {
        var stateId = $('#PortId').val();
        $.ajax({
            url: '/ContributionRate/GetValueFromDDL',
            type: "GET",
            dataType: "JSON",
            data: { PortId: stateId },
            success: function (portnumber) {
                $("#PortNumber").html(""); // clear before appending new list 
                $("#PortNumber").val(portnumber);
            }
        });
    }
</script>
